package com.problem.leetcode;

import com.google.common.base.Stopwatch;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

/**
 * @author didi
 * @DESCRIPTION
 * @create 2019-05-02 15:23
 **/

public class Problem804 {

    private final static List<String> marsk = Arrays.asList(".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..",
                                                            ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.",
                                                            "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..");

    public int uniqueMorseRepresentations(String[] words) {

        HashSet<String> result = new HashSet<>();

        for (int index = 0; index < words.length; index++) {
            StringBuilder stringBuilder = new StringBuilder();
            String        ele           = words[index];
            for (int cindex = 0; cindex < ele.length(); cindex++) {
                stringBuilder.append(marsk.get(ele.charAt(cindex) - 'a'));
            }
            result.add(stringBuilder.toString());
        }
        return result.size();
    }

    public static void main(String[] args) throws InterruptedException {
        Stopwatch stopwatch = Stopwatch.createStarted();
        new Problem804().uniqueMorseRepresentations(new String[]{"gin", "zen", "gig", "msg"});
        stopwatch.stop();
        System.out.println(stopwatch.toString());
    }

}
